﻿<style type="text/css">
	#tk{padding:0 0 0 5px;margin-left:5px;font-family:Tahoma, Geneva, sans-serif; text-align:center; color:#F00;}
	#tksp{font-family:Tahoma, Geneva, sans-serif; font-weight::bold; color:#06F; font-size:26px; margin-bottom:10px;}
	#cl{padding:0 0 0 5px;margin-left:5px;margin-top:10px;font-family:Tahoma, Geneva, sans-serif;}
</style>
<?php
if(!isset($_SESSION['user_id'])){//if 1
echo '<font id=cl color="#FF0000" size="4.5">Vui lòng đăng nhập trước khi sử dụng tính năng này!!!</font>';
require_once 'include/dangnhap.php';
}
else{ 
if(isset($_POST['manufacturer'])&& isset($_POST['price'])){//if 2
	
	$nsx=$_POST["manufacturer"];
	$price=$_POST['price'];
	$strSQL = "SELECT pd_id, cat_id, pd_name, pd_price, pd_image FROM tbl_product where";
	$result = mysql_query($strSQL);

	if($nsx!="")
		$strSQL .= " cat_id ='$nsx'";					
	if($nsx!=""&&$price!="") $strSQL .="and";			
	if($price!="")
		if($price=="1")
			$strSQL.="(pd_price < 100)";
		else
		if ($price=="2")
			$strSQL.="(pd_price between 100 And 500)";
		else
		if($price=="3")
			$strSQL .="(pd_price > 500)";
			
	$result=mysql_query($strSQL);
	if(@mysql_num_rows($result)==0) echo"<h3 id=tk>Không tìm thấy kết quả bạn muốn tìm!!!</h3>";//if 3
	else {
?>
<p align="center" id="tksp">Sản phẩm cần tìm</p>
<?php
echo "<table cellpadding=0 cellspacing=0 width=90% border=1 align=center>";
echo"<tr>
		<td align=center>Mã SP</td>
		<td align=center>Mã NSX</td>
		<td align=center>Tên sản phẩm</td>		
		<td align=center>Giá</td>		
		<td align=center>Hình ảnh</td>
		<td align=center>Chi tiết</td>"; 
while ($row = @mysql_fetch_array($result)){ 
echo"<tr>";
	$pdId=$row[0];
	$catId=$row[1];
	$product = getProductDetail($pdId, $catId);
	extract($product);
  for ($i=0; $i<mysql_num_fields($result); $i++){	
  	if($i==4){
		  echo "<td align=center width=100px><img src='".$pd_image."' width=25%></td>";
	  }else{
	  echo "<td width=50 align=center> $row[$i]</td>"; 
	  }
	}
	  echo"<td width=80px align=center><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pdId" . "\">Xem</a></td>";
		echo "</td>";
		echo"</tr>";
  
	} 

echo"</table>";
 
} //if 3
}//if 2
}//if 1